<?php
/**
 * @version		$Id: default.php 5 2011-12-19 14:45:07Z netix.mail@gmail.com $
 * @package		ALM Hoster
 * @desription	Web hosting and domain menager for resellers
 * @subpackage	Components
 * @copyright	Copyright (C) 2011 ALM Studio. All rights reserved.
 * @author		ALM Studio
 * @email		info@alm-studio.net
 * @link		http://alm-studio.net
 * @license		Commercial
 */
 
defined('_JEXEC') or die('Restricted Access');

JHtml::_('behavior.tooltip');
JHTML::_('script','system/multiselect.js',false,true);
$listOrder	= $this->escape($this->state->get('list.ordering'));
$listDirn	= $this->escape($this->state->get('list.direction'));
$config = JFactory::getConfig();
$params = JComponentHelper::getParams('com_almhoster');
$currency 	= $params->get("UseCurrency");
?>
<script>
function createInvoice(delUrl) {
	  if (confirm()) {
	    document.location = delUrl;
	  }
	}
</script>
<form action="<?php echo JRoute::_('index.php?option=com_almhoster&view=invoices'); ?>" method="post" name="adminForm">
	<fieldset id="filter-bar">	
		<div class="filter-select fltrt">
			<select name="filter_client_id" class="inputbox" onchange="this.form.submit()">
				<option value=""><?php echo JText::_('COM_ALMHOSTER_FILTER_BY_CLIENT');?></option>
				<?php echo JHtml::_('select.options', $this->client, 'value', 'text', $this->state->get('filter.client_id'));?>
			</select>			
			<select name="filter_order_id" class="inputbox" onchange="this.form.submit()">
				<option value=""><?php echo JText::_('COM_ALMHOSTER_FILTER_BY_ORDER');?></option>
				<?php echo JHtml::_('select.options', $this->order, 'value', 'text', $this->state->get('filter.order_id'));?>
			</select>
			<select name="filter_status_id" class="inputbox" onchange="this.form.submit()">
				<option value=""><?php echo JText::_('COM_ALMHOSTER_FILTER_BY_STATUS');?></option>
				<?php echo JHtml::_('select.options', $this->status, 'value', 'text', $this->state->get('filter.status_id'));?>
			</select>			
	</div>
	</fieldset>
<div class="clr"></div>
<table class="adminlist">
	<thead>
			<tr>
	<th width="5">
		<?php echo JHtml::_('grid.sort',  'Id', 'InvoiceId', $listDirn, $listOrder); ?>
	</th>
	<th width="10">
		<input type="checkbox" name="toggle" value="" onclick="checkAll(<?php echo count($this->items); ?>);" />
	</th>
	<th width="5%">
		<?php echo JHtml::_('grid.sort',  'COM_ALMHOSTER_INVOICE_ORDER', 'InvoiceOrder', $listDirn, $listOrder); ?>
	</th>			
	<th class="title">
		<?php echo JHtml::_('grid.sort',  'COM_ALMHOSTER_INVOICE_PRODUCT', 'InvoiceProduct', $listDirn, $listOrder); ?>
	</th>
	<th width="11%">
		<?php echo JHtml::_('grid.sort',  'COM_ALMHOSTER_INVOICE_DATE', 'InvoiceDate', $listDirn, $listOrder); ?>
	</th>
		<th width="12%">
		<?php echo JHtml::_('grid.sort',  'COM_ALMHOSTER_INVOICE_CLIENT', 'InvoiceClient', $listDirn, $listOrder); ?>
	</th>
		<th width="8%">
		<?php echo JHtml::_('grid.sort',  'COM_ALMHOSTER_INVOICE_AMOUNT', 'InvoiceAmount', $listDirn, $listOrder); ?>
	</th>
	<th width="8%">
		<?php echo JHtml::_('grid.sort',  'COM_ALMHOSTER_INVOICE_DUE', 'InvoiceDue', $listDirn, $listOrder); ?>
	</th>
	<th width="8%">
		<?php echo JHtml::_('grid.sort',  'COM_ALMHOSTER_INVOICE_IP', 'InvoiceIp', $listDirn, $listOrder); ?>
	</th>
	<th width="6%">
		<?php echo JHtml::_('grid.sort',  'COM_ALMHOSTER_INVOICE_STATUS', 'InvoiceStatus', $listDirn, $listOrder); ?>
	</th>
	<th>
		<?php echo JText::_('COM_ALMHOSTER_ACTIONS'); ?>
	</th>
	</tr>
</thead>
<tfoot>	
	<tr>
	<td colspan="11">
		<?php echo $this->pagination->getListFooter(); ?></td>
	</tr>		
</tfoot>
<tbody>
	<?php foreach($this->items as $i => $item): 
?>
	<tr class="row<?php echo $i % 2; ?>">
		<td>
			<?php echo $item->InvoiceId; ?>
		</td>
		<td>
			<?php echo JHtml::_('grid.id', $i, $item->InvoiceId); ?>
		</td>
		<td>
			<?php echo $item->InvoiceOrder; ?>
		</td>
		<td>
		<a href="<?php echo JRoute::_('index.php?option=com_almhoster&task=invoice.edit&InvoiceId=' . $item->InvoiceId); ?>">
				<?php echo $item->InvoiceProduct; ?>
				</a>
		</td>
		<td align="center">
			<?php echo $item->InvoiceDate; ?>
		</td>
		<td>
			<?php echo $item->client; ?>
		</td>
		<td align="right">
			<?php echo $item->InvoiceAmount, JText::_(' '), JText::_('COM_ALMHOSTER_BILLING_CURRENCY_'.$currency); ?>
		</td>
		<td align="center">
			<?php echo $item->InvoiceDue; ?>
		</td>
		<td align="center">
			<?php echo $item->InvoiceIp; ?>
		</td>
		<?php
					if ($item->OrderStatus == 0) { ?>
			<td align="center" style= "background-color: #faf29f">
				<strong>
					<?php echo JText::_('COM_ALMHOSTER_LIST_INVOICE_STATUS_'.$item->InvoiceStatus); ?>
				</strong>
			</td>
				<?php
					} if ($item->OrderStatus == 1) { ?>
			<td align="center" style= "background-color: #a8db99">
				<strong>
				<?php echo JText::_('COM_ALMHOSTER_LIST_INVOICE_STATUS_'.$item->InvoiceStatus); ?>
				</strong>
			</td>
			<?php
				} if ($item->OrderStatus == 2) { ?>
			<td align="center" style= "background-color: #ff6666">
				<strong>
				<?php echo JText::_('COM_ALMHOSTER_LIST_INVOICE_STATUS_'.$item->InvoiceStatus); ?>
				</strong>
			</td>				
				<?php
				}	if ($item->OrderStatus == 3) { ?>
			<td align="center" style= "background-color: #c9ddde">
				<strong>
				<?php echo JText::_('COM_ALMHOSTER_LIST_INVOICE_STATUS_'.$item->InvoiceStatus); ?>
				</strong>
			</td>
				<?php
					} ?>
			<td align="center">	
				<a type="image"  href="<?php echo JRoute::_('index.php?option=com_almhoster&task=orders.sendEmail&InvoiceId=' . $item->InvoiceId); ?>" 
				onclick="return confirm('<?php echo JText::_('COM_ALMHOSTER_CONFIRM_RESEND_INVOICE_EMAIL').$item->InvoiceId.' - '.$item->InvoiceProduct.'?'; ?>')"">
					<img src="../media/com_almhoster/images/email.png" title="<?php echo JText::_('COM_ALMHOSTER_RESEND_INVOICE_EMAIL'); ?>"> 
				</a>
			</td>
	</tr>
<?php endforeach; ?>
</tbody>
	</table>
	<div>
		<input type="hidden" name="task" value="" />
		<input type="hidden" name="boxchecked" value="0" />
		<input type="hidden" name="filter_order" value="<?php echo $listOrder; ?>" />
		<input type="hidden" name="filter_order_Dir" value="<?php echo $listDirn; ?>" />
		<?php echo JHtml::_('form.token'); ?>
	</div>
</form>
